@extends('layouts.default') @section('main')
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <link rel="stylesheet" href="/css/chosen.css" />
    <script type="text/javascript" src="{{URL::asset('js/')}}/ajaxfileupload.js"></script>
    <script type="text/javascript" src="/js/chosen.jquery.min.js"></script>
    <script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>
    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
                            class="icon-home"></i> 首页</a>
                <a href="{{url('category/index')}}" class="tip-bottom">行业分类管理</a>
                <a href="#" class="current">分类信息修改</a>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span9">
                    <div class="widget-box">
                        <div class="widget-title">
						<span class="icon"> <i class="icon-align-justify"></i>
						</span>
                            <h5>基础信息</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <form action="{{url('category/edit')}}" method="post" id="adForm" class="form-horizontal">
                                <div class="control-group">
                                    <label class="control-label">分类ID :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="id" value="{{$me->id}}" readonly="readonly" placeholder="会员ID" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>行业分类名称 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="name" value="{{$me->name}}" placeholder="行业分类名称"  />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>code :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="code" value="{{$me->code}}"  placeholder="code" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>排序 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="sort" value="{{$me->sort}}"  placeholder="sort" />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>状态 :</label>
                                    <div class="controls">
                                        <input type="radio"  name="status"  value="1" @if($me->status==1)checked="checked"@endif/>正常
                                        <input type="radio"  name="status"  value="0" @if($me->status==0)checked="checked"@endif/>禁用
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>是否热门 :</label>
                                    <div class="controls">
                                        <input type="radio"  name="hot"  value="1" @if($me->hot==1)checked="checked"@endif/>热门
                                        <input type="radio"  name="hot"  value="0" @if($me->hot==0)checked="checked"@endif/>不热门
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>是否推荐 :</label>
                                    <div class="controls">
                                        <input type="radio"  name="recommend"  value="1" @if($me->status==1)checked="checked"@endif/>推荐
                                        <input type="radio"  name="recommend"  value="0" @if($me->status==0)checked="checked"@endif/>不推荐
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">父分类 :</label>
                                    <div class="controls">
                                        <select  name="upid" class="span11" >
                                            @if($me->category)
                                            <option value="">请选择父分类</option>
                                            @else
                                                <option value="">请选择父分类</option>
                                            @endif
                                            @foreach($others as $v)
                                                <option value="{{$v->id}}">{{$v->name}}</option>
                                            @endforeach
                                        </select>
                                    </div>

                                <div class="form-actions">
                                    <input type="hidden" class="span11" name="formType" id="formType" value="edit"  />
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <button type="button" id="doSave" class="btn btn-success">确认修改</button>
                                </div>
                            </form>
                            @include('errors.list')
                            @include('message.flash')
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        $(document).ready(function(){
            //初始化
            $(".chzn-select").chosen();

        });

        $("#doSave").click(function(){
            ajaxRequest($('#adForm').serializeArray(),$('#adForm').attr('action'),function(data){
                if(data.status){
                    alert(data.message);
                    window.location.href = data.forwardUrl;
                }else{
                    alert(data.message);
                }
            });
        });

        $("#city").change(function() {
            $("#zone").empty();
            $.post("{{url('zone/children')}}", {
                id: $(this).val()
            }, function(data) {
                if (data.status) {
                    var html = '<option value="">城市</option>';
                    $.each(data.message, function(i, n) {
                        html += "<option value='"+n.id+"'>"+n.name+"</option>";
                    });
                    $("#zone").html(html);
                }
            }, 'json');
        });

    </script>
@stop
